<template>
<div id="tmpl">
<mt-header fixed title="临溪阁.黑科技商城"></mt-header>
	<div v-if="isshow" id="back">
		<a href="javascript:;" @click="backto">返回</a>
	</div>
	
	<router-view></router-view>
	<nav class="mui-bar mui-bar-tab">
		<router-link class="mui-tab-item" to="/home">
			<span class="mui-icon mui-icon-home"></span>
			<span class="mui-tab-label">首页</span>
		</router-link>
		<router-link class="mui-tab-item" to="/shopcar">
			<span class="mui-icon mui-icon-email"><span class="mui-badge" id="badge">0</span></span>
			<span class="mui-tab-label">购物车</span>
		</router-link>
		<router-link class="mui-tab-item" to="#tabbar-with-contact">
			<span class="mui-icon mui-icon-contact"></span>
			<span class="mui-tab-label">会员</span>
		</router-link>
		<router-link class="mui-tab-item" to="#tabbar-with-map">
			<span class="mui-icon mui-icon-gear"></span>
			<span class="mui-tab-label">设置</span>
		</router-link>
	</nav>

</div>
	
</template>
<script>
import {vm,COUNTSTR} from './kits/vm.js';
vm.$on(COUNTSTR,function(count){
	var badge = document.getElementById('badge');
	badge.innerText = parseInt(badge.innerText)+count;
})
	export default{
		data(){
			return{
				isshow:false
			}
		},
		created(){},
		watch:{
			'$route':function(newroute,oldroute){
				if (newroute.path.toLowerCase() == '/home') {
					this.isshow = false;
				}else{
					this.isshow = true;
				}
			}
		},
		methods:{
			backto(){
				this.$router.go(-1);
			}

		}
	}
</script>
<style scoped>
	#back {
		width: 60px;
		position: fixed;
		top: 10px;
		left:10px;
		z-index: 99999;
	}
	#back a{
		color: #fff;
		font-size: 16px;
		font-weight: bold;
	}
</style>